/* Sets the values of the POUT, SEL, and BUSY bits for the data
direction register, as given by the code ubBitCode. */
#define SETDCIA(x) (pciab->ciaddra|=(x))
#define CLRDCIA(x) (pciab->ciaddra&=~(x))
static void SetDirectionBits(UBYTE ubBitCode)
{
if (ubBitCode == 0) return;
if (ubBitCode & SAMPBIT_POUTCLR) CLRDCIA(CIAF_PRTRPOUT);
if (ubBitCode & SAMPBIT_POUTSET) SETDCIA(CIAF_PRTRPOUT);
if (ubBitCode & SAMPBIT_SELCLR) CLRDCIA(CIAF_PRTRSEL);
if (ubBitCode & SAMPBIT_SELSET) SETDCIA(CIAF_PRTRSEL);
if (ubBitCode & SAMPBIT_BUSYCLR) CLRDCIA(CIAF_PRTRBUSY);
if (ubBitCode & SAMPBIT_BUSYSET) SETDCIA(CIAF_PRTRBUSY);
if ((ubSamplerType == SAMPLER_CUSTOM)&&
(ubBitCode != (SAMPBIT_POUTSET | SAMPBIT_SELSET | SAMPBIT_BUSYSET))) printf("SetDirectionBits: Executed %s, direction bits are now %s\n",BitsToString(ubBitCode),RegToString(pciab->ciaddra));
}
/* Returns the changes a given byte code will do/has done. */
static char * BitsToString(UBYTE ubCode)
{
static char szResult[13];
memset(szResult,0,sizeof(szResult));
if (ubCode & SAMPBIT_POUTCLR) strcat(szResult,"-P");
if (ubCode & SAMPBIT_POUTSET) strcat(szResult,"+P");
if (ubCode & SAMPBIT_SELCLR) strcat(szResult,"-S");
if (ubCode & SAMPBIT_SELSET) strcat(szResult,"+S");
if (ubCode & SAMPBIT_BUSYCLR) strcat(szResult,"-B");
if (ubCode & SAMPBIT_BUSYSET) strcat(szResult,"+B");
return(szResult);
}
/* Returns the state of the register. */
static char * RegToString(UBYTE ubReg)
{
static char szResult[25];
sprintf(szResult,"P=%i,B=%i,S=%i",
(ubReg & CIAF_PRTRPOUT) != 0,
(ubReg & CIAF_PRTRBUSY) != 0,
(ubReg & CIAF_PRTRSEL) != 0);
return(szResult);
}
/* Should work much like Toccata's T_FindFrequency function ... */